<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	template="/common/template.xhtml">
	<ui:define name="content">
		<f:view>
	<f:loadBundle var="text" basename="#{medicamentList.bundleName}" />
	<h:head>
		<title>#{text['medicamentList.title']}</title>
		<meta name="heading" content="#{text['medicamentList.heading']}" />
		<meta name="menu" content="StockMenu" />
	</h:head>
	<body id="medicamentList">

		<h2>#{text['medicamentList.heading']}</h2>

		<p>#{text['medicamentList.message']}</p>

		<h:form id="editMedicament" styleClass="form-horizontal">

			<p:dataTable id="medicaments" var="medicament"
				value="#{medicamentList.medicaments}"
				styleClass="table table-striped table-hover"
				sortBy="#{medicamentList.sortColumn}" paginator="true" rows="15"
				paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="15,25,50">

				<p:column headerText="#{text['medicament.libelle']}"
					filterBy="#{medicament.libelle}" filterMatchMode="contains">
					<h:outputText value="#{medicament.libelle}" escape="true" />
				</p:column>

				<p:column headerText="#{text['medicament.forme']}"
					filterBy="#{medicament.forme.libelle}" filterMatchMode="contains">
					<h:outputText value="#{medicament.forme.libelle}" escape="true" />
				</p:column>

				<p:column headerText="#{text['medicament.nbrEnStock']}"
					filterBy="#{medicament.nbrEnStock}" filterMatchMode="startsWith">
					<h:outputText value="#{medicament.nbrEnStock}" escape="true" />
				</p:column>

				<p:column headerText="#{text['medicament.prixUnit']}"
					filterBy="#{medicament.prixUnit}" filterMatchMode="startsWith">
					<h:outputText value="#{medicament.prixUnit}" escape="true" />
				</p:column>

				<p:column width="10">
					<h:commandLink action="#{medicamentForm.edit}" class="icon-pencil"
						title="#{text['button.edit']}">
						<f:param name="id" value="#{medicament.id}" />
						<f:param name="from" value="list" />
					</h:commandLink>
				</p:column>

				<p:column width="10">
					<p:commandLink id="DETAIL-medicament" update=":editMedicament:display" oncomplete="dlg.show()" styleClass="icon-eye-open" title="#{text['button.view']}">
		                <f:setPropertyActionListener value="#{medicament}" target="#{medicamentForm.medicament}" />
		            </p:commandLink>
				</p:column>

				<p:column width="10">
					<h:commandLink action="#{medicamentForm.delete}" class="icon-trash"
						onclick="return confirmMessage('#{text['medicament.delete.confirm']}')"
						title="#{text['button.delete']}">
						<f:param name="id" value="#{medicament.id}" />
						<f:param name="from" value="list" />
					</h:commandLink>
				</p:column>
				
			</p:dataTable>
			<p:dialog header="#{text['medicamentDetail.title']}" resizable="false" width="40%" id="display" widgetVar="dlg" showEffect="fade" hideEffect="highlight" modal="true">
				<h:form id="medicamentForm" styleClass="form-horizontal">

			<div class="control-group">
				<h:outputLabel styleClass="control-label"
					value="#{text['medicament.libelle']}" />
				<div class="controls">
					<h:outputLabel styleClass="control-label"
					value="#{medicamentForm.medicament.libelle}" />
				</div>
			</div>

			<div class="control-group">
				<h:outputLabel styleClass="control-label"
					value="#{text['medicament.forme']}" />
				<div class="controls">
					<h:outputLabel styleClass="control-label"
					value="#{medicamentForm.medicament.forme.libelle}" />
				</div>
			</div>

			<div class="control-group">
				<h:outputLabel styleClass="control-label"
					value="#{text['medicament.lowEnStock']}" />
				<div class="controls">
				<h:outputLabel styleClass="control-label"
					value="#{medicamentForm.medicament.lowEnStock}" />
				</div>
			</div>
			
			<div class="control-group">
				<h:outputLabel styleClass="control-label"
					value="#{text['medicament.nbrEnStock']}" />
				<div class="controls">
					<h:outputLabel styleClass="control-label"
						value="#{medicamentForm.medicament.nbrEnStock}" />
				</div>
			</div>
			
			<div class="control-group">
				<h:outputLabel styleClass="control-label"
					value="#{text['medicament.prixAchat']}" />
				<div class="controls">
					<h:outputLabel styleClass="control-label"
						value="#{medicamentForm.medicament.prixAchat}" />
				</div>
			</div>
			
			<div class="control-group">
				<h:outputLabel styleClass="control-label"
					value="#{text['medicament.prixUnit']}" />
				<div class="controls">
				<h:outputLabel styleClass="control-label"
					value="#{medicamentForm.medicament.prixUnit}" />
				</div>
			</div>
			
		</h:form>
			</p:dialog>  
		</h:form>
	</body>
</f:view>
	</ui:define>
</ui:composition>
